<?php

class Forum_TopicController extends Zend_Controller_Action
{

  public function init()
  {

  }

  public function indexAction()
  {
    // action body
  }

  public function deleteAction()
  {
    // action body
  }

  public function editAction()
  {
    // action body
  }

  public function viewAction()
  {
    $this->view->form = $form = new Forum_Form_Post_Create();
    $this->view->viewer = $viewer = Engine_Api::_()->application()->getViewer();
    if ($this->getRequest()->isPost()) {
      $data = $this->getRequest()->getPost();
      if ($form->isValid($data)){
        $post = new Forum_Model_Post();
        $post->setUser($viewer);
        $post->topic_id = 1;
        $post->forum_id = 1;
        $post->creation_date = date("Y-m-d H:i:s");
        $post->fill($data);
        $post->save();
        $this->redirect('forum/topic/view');
      }
    }

    $posts = new Forum_Model_DbTable_Posts();
    $select = $posts->select();
    $select->where('topic_id = ?', 1)
      ->order('post_id');

    $this->view->paginator = $paginator = Zend_Paginator::factory($select);
    $paginator->setItemCountPerPage(10);
    $paginator->setCurrentPageNumber($this->_getParam('page'));

  }

  public function closeAction()
  {
    // action body
  }


}









